//
//  GSShader.cpp
//  GSEngine
//
//  Created by Гукун Александр on 2/13/14.
//  Copyright (c) 2014 SNK. All rights reserved.
//

#include "GSShader.h"

namespace GSEngine
{
    GSShader::GSShader():m_data(nullptr), m_isLoaded(false)
    {
        
    }
    GSShader::~GSShader()
    {
        if (m_data != nullptr)
            delete m_data;
    }
    void GSShader::loadShaderSource(const char* path, const char* permission)
    {
        m_file = fopen(path, permission);
        if (m_file != NULL)
        {
            fseek(m_file, 0, SEEK_END);
            m_size = ftell(m_file);
            fseek(m_file, 0, SEEK_SET);
            m_data = new unsigned char[m_size];
            fread(m_data, sizeof(unsigned char), m_size, m_file);
            m_isLoaded = true;
            fclose(m_file);
        }
    }
    bool GSShader::isLoadedShader()
    {
        return m_isLoaded;
    }
    unsigned char* GSShader::getData()
    {
        return m_data;
    }
    int GSShader::getSize()
    {
        return m_size;
    }
}